﻿using System;
using EyFramework.SocketServer.Behavior;
using EyFramework.SocketServer.InData;
using EyFramework.SocketServer.OutData;
using Insurance.ReadCard;
using Newtonsoft.Json;
using WebSocketSharp;
using WebSocketSharp.Server;

namespace EyFramework.SocketServer
{
    /// <summary>
    /// 医保WebSocket调用成，完成Chrome网页与本地C#程序完成通信的过程
    /// </summary>
    public class InsuranceBehavior : BaseBehavior
    {
        public override string doBusiness(string inData)
        {
            ReadCardInData readCardInData = JsonConvert.DeserializeObject<ReadCardInData>(inData);
            CardFormat cardFormat = null;
            if (readCardInData.ReadType == "1")
            {
                //实体卡读卡
                cardFormat = ReadCardService.ReadCityCard();
            }
            else if (readCardInData.ReadType == "2")
            {
                //电子凭证读卡
                cardFormat = ReadCardService.ReadDzpzCard();
            }
            else if (readCardInData.ReadType == "3")
            {
                //电子凭证读卡
                cardFormat = ReadCardService.ReadVirtualCard();
            }
            else
            {
                //没有指定读卡的方式，则直接弹出读卡选中框
                cardFormat = ReadCardService.ReadIcCard();
            }

            return ReturnResult.Success(cardFormat);
        }
    }
}